package com.x.chalk.controller;

import com.x.chalk.config.SystemConfig;
import com.x.chalk.dto.UsefulNewsCommentDto;
import com.x.chalk.service.intf.UsefulNewsCommentService;
import com.x.chalk.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/usefulnewscomment/")
@Api(tags = "干货中评论以及评论回复")
@CrossOrigin
public class UsefulNewsCommentController {
    @Autowired
    private UsefulNewsCommentService service;

    /** 新增*/
    @PostMapping("add.do")
    public R add(@RequestBody UsefulNewsCommentDto dto, HttpServletRequest request){
        return service.add(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    /**
     * 评论回复
     * @param dto
     * @param request
     * @return
     */
    @PostMapping("addreply.do")
    public R addreply(@RequestBody UsefulNewsCommentDto dto, HttpServletRequest request){
        return service.addReply(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }
}
